home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / cross / ava-0.2.5.lha / ava-0.2.5 / avalib / avr.inc < prev    next >
Encoding:
Text File  |  1999-03-23  |  3.1 KB  |  159 lines

  1. /*
  2.     avr.inc
  3.  
  4.     version 0.2.1
  5.             
  6.     AVR Declarations of the I/O Registers
  7.     Reference: AVR Enhanced RISC Micro-controller Databook 1997-1999
  8.     
  9.     Uros Platise (c) 1997-1999
  10.  
  11.     -------    
  12.     This file was entirely rearranged and updated on 24. January 1999.
  13.     Last update: 14.2.1999
  14. */
  15.  
  16. #ifndef __AVR_INC
  17. #define __AVR_INC
  18.  
  19. /* 
  20.   Common Macros
  21.   -------------
  22. */
  23.  
  24. /* Calculate Flash Address from the label */
  25. #define FADDR(x)     (x>>1)
  26.  
  27. /* Define Constant from label */
  28. #define DC_ADDR(x)    dc.w FADDR(x)
  29.  
  30. /* Calculate bit value from bit number! */
  31. #define BV(x)    (1<<x)
  32.  
  33. /* Calculate Address of the Memory Mapped I/O Registers */
  34. #if __ERAM_SIZE > 0
  35. #define mmio(x)    ((x)+0x20)
  36. #endif
  37.  
  38. /* Exclude lower/higher eight bits */
  39. #define low(x)  ((x)&0xff)
  40. #define high(x) (((x)>>8)&0xff)
  41.  
  42. /* Exclude lower/higher eight bits from the FLASH address */
  43. #define flow(x)  (FADDR(x)&0xff)
  44. #define fhigh(x) ((FADDR(x)>>8)&0xff)
  45.  
  46.  
  47.  
  48. /*
  49.   Device Peripheral Selection
  50.   ---------------------------
  51.   The following statements declares peripheral sections to be
  52.   included according to the specifed device.
  53. */
  54.  
  55. #ifdef AT90S1200
  56. #include "avr/1200def.inc"
  57. #endif
  58.  
  59. #ifdef AT90S2313
  60. #include "avr/2313def.inc"
  61. #endif
  62.  
  63. #ifdef AT90S2323
  64. #include "avr/2323def.inc"
  65. #endif
  66.  
  67. #ifdef AT90S2333
  68. #include "avr/2333def.inc"
  69. #endif
  70.  
  71. #ifdef AT90S2343
  72. #include "avr/2343def.inc"
  73. #endif
  74.  
  75. #ifdef AT90S4414
  76. #include "avr/4414def.inc"
  77. #endif
  78.  
  79. #ifdef AT90S4433
  80. #include "avr/4433def.inc"
  81. #endif
  82.  
  83. #ifdef AT90S4434
  84. #include "avr/4414def.inc"
  85. #endif
  86.  
  87. #ifdef AT90S8515
  88. #include "avr/8515def.inc"
  89. #endif
  90.  
  91. #ifdef AT90S8535
  92. #include "avr/8535def.inc"
  93. #endif
  94.  
  95. #ifdef ATmega103
  96. #include "avr/M103def.inc"
  97. #endif
  98.  
  99. #ifdef ATmega603
  100. #include "avr/M603def.inc"
  101. #endif
  102.  
  103.  
  104. /*
  105.   Peripheral Additional Macros
  106.   ----------------------------
  107. */
  108.  
  109. /* SM Abbreviations */
  110. #define SM_POWERDOWN    SM
  111. #define SM_IDLE        0
  112. #define SM_SAVE        (BV(SM0)+BV(SM1))
  113.  
  114. /* Watchdog Prescaler Shortcuts WDPx; x [miliseconds] */
  115. #define WDP16    0
  116. #define WDP32    BV(WDP0)
  117. #define WDP64    BV(WDP1)
  118. #define WDP128    (BV(WDP1)+BV(WDP0))
  119. #define WDP256    BV(WDP2)
  120. #define WDP512    (BV(WDP2)+BV(WDP0))
  121. #define WDP1024    (BV(WDP2)+BV(WDP1))
  122. #define WDP2048    (BV(WDP2)+BV(WDP1)+BV(WDP0))
  123.  
  124. /* 8 bit Counter/Timer Prescaler Values */
  125. #define TMC8_STOP    0
  126. #define TMC8_CK        BV(CS00)
  127. #define TMC8_CK8    BV(CS01)
  128. #define TMC8_CK64    (BV(CS00)+BV(CS01))
  129. #define TMC8_CK256    BV(CS02)
  130. #define TMC8_CK1024    (BV(CS02)+BV(CS00))
  131. #define TMC8_EXTFAL    (BV(CS02)+BV(CS01))
  132. #define TMC8_EXTRIS    (BV(CS02)+BV(CS01)+BV(CS00))
  133.  
  134. /* 16 bit Timer Counter Prescaler Values */
  135. #define TMC16_STOP    0
  136. #define TMC16_CK    BV(CS10)
  137. #define TMC16_CK8    BV(CS11)
  138. #define TMC16_CK64    (BV(CS10)+BV(CS11))
  139. #define TMC16_CK256    BV(CS12)
  140. #define TMC16_CK1024    (BV(CS12)+BV(CS10))
  141. #define TMC16_EXTFAL    (BV(CS12)+BV(CS11))
  142. #define TMC16_EXTRIS    (BV(CS12)+BV(CS11)+BV(CS10))
  143.  
  144. /* SPI Prescaler Values at SYS_CLK = 8.000 MHz */
  145. #define SPI_CK4        0            /*    2 Mbit */
  146. #define SPI_CK16    BV(SPR0)        /*  500 kbit */
  147. #define SPI_CK64    BV(SPR1)        /*  125 kbit */
  148. #define SPI_CK128    (BV(SPR1)+BV(SPR0))    /* 62.5 kbit */
  149.  
  150. /* UART Baudrate Expression
  151.    fclk - system clock
  152.    baudrate - as 1200, 2400, 9600, ... 
  153. */
  154. #define UART_UBBR(fclk,baudrate)    ((fclk/(16*baudrate))-1)
  155.  
  156. #endif
  157. /* eof: avr.inc */
  158.  
  159.